(function(){
    $('#search_building').bind('input propertychange',function() { 
        var input_value = $(this).val();
        var city_id = $('#showcity').attr('city-id');
        //alert(city_id);return false;
        if(input_value != "" || undefined){
            var URL = "/buildings/front/buildinginfo/search";
            $.ajax({
                type:"get",
                url:URL,
                data: {'keyword':input_value,'city_id':city_id},
                dataType:'json',
                success:function(msg){
                    //console.log(msg);
                    if(msg){
                        console.log(msg);
                        var len = msg.length;
                        //console.log(len);
                        var str = "";
                        if (msg != 2 && len > 0) {
                            for (var i = 0; i < len; i++) {
                                str += '<li bid="' + msg[i].building_id + '" citycode="' + msg[i].city_info['code'] + '" ><a href="/building/' + msg[i].city_info['code'] + '/' + msg[i].building_id + '/campaign"> <h3>' + msg[i].name + '</h3><p>' + msg[i].address_show + '</p></a></li>';
                            }
                            
                        } else {
                            str += '<li style="width:275px;height:25px;line-height:25px;">无</li>';
                        }
                        $(".search-list").show();
                        $(".search-list").html(str);
                    }
                },
            })
        }else{
            $(".search-list").hide();
        }
        //console.log(input_value);
     });


    $(".new-city").mouseover(function(){
        $(".contain").show();
    });

    $(".new-city").mouseout(function(){
        $(".contain").hide();
    });

    $('#search_fang').bind('input propertychange',function() { 
        var input_value = $(this).val();
        var city_id = $('#showcity').val();
        // alert(city_id);return false;
        if(input_value != "" || undefined){
            var URL = "/buildings/front/home/searchFang";
            $.ajax({
                type:"get",
                url:URL,
                data: {'keyword':input_value,'city_id':city_id},
                dataType:'json',
                success:function(msg){
                    //console.log(msg);
                    if(msg){
                        console.log(msg);
                        var len = msg.length;
                        //console.log(len);
                        var str = "";
                        if (msg != 2 && len > 0) {
                            for (var i = 0; i < len; i++) {
                                str += '<li class="search-item" bid="' + msg[i].building_id + '" citycode="' + msg[i].city_info['code'] + '" ><a href="/building/' + msg[i].city_info['code'] + '/' + msg[i].building_id + '/campaign"> <p class="building-title">' + msg[i].name + '</p><p class="building-detail">' + msg[i].address_show + '</p></a></li>';
                            }
                            
                        } else {
                            str += '<li class="search-item"><p class="building-title">找不到相关房源</li>';
                        }
                        $(".search-list").show();
                        $(".search-list").html(str);
                    }
                },
            })
        }else{
            $(".search-list").hide();
        }
        //console.log(input_value);
     }); 

})()
// 品友 fang90.com 一键拨打转化代码
function pyRegisterCvt(telephone){
    var w=window,d=document,e=encodeURIComponent;
    var b=location.href,c=d.referrer,f,g=d.cookie,h=g.match(/(^|;)\s*ipycookie=([^;]*)/),i=g.match(/(^|;)\s*ipysession=([^;]*)/);
    if (w.parent!=w){f=b;b=c;c=f;};u='//stats.ipinyou.com/cvt?a='+e('Nbs.c7s.35PsC7iVEtcB6xqz0ujGTX')+'&c='+e(h?h[2]:'')+'&s='+e(i?i[2].match(/jump\%3D(\d+)/)[1]:'')+'&u='+e(b)+'&r='+e(c)+'&rd='+(new Date()).getTime()+'&ProductList='+e(telephone)+'&e=';
    (new Image()).src=u;
}

// 品友 fang90.com 立即预约转化代码
function pyYuyueCvt(){
    var w=window,d=document,e=encodeURIComponent;
    var b=location.href,c=d.referrer,f,g=d.cookie,h=g.match(/(^|;)\s*ipycookie=([^;]*)/),i=g.match(/(^|;)\s*ipysession=([^;]*)/);
    if (w.parent!=w){f=b;b=c;c=f;};u='//stats.ipinyou.com/cvt?a='+e('Nbs.c7s.35PsC7iVEtcB6xqz0ujGTX')+'&c='+e(h?h[2]:'')+'&s='+e(i?i[2].match(/jump\%3D(\d+)/)[1]:'')+'&u='+e(b)+'&r='+e(c)+'&rd='+(new Date()).getTime()+'&e=';
    (new Image()).src=u;
}

// 品友 fang90.com 咨询转化代码
function pyRegisterZixunCvt(){
    var w=window,d=document,e=encodeURIComponent;
    var b=location.href,c=d.referrer,f,g=d.cookie,h=g.match(/(^|;)\s*ipycookie=([^;]*)/),i=g.match(/(^|;)\s*ipysession=([^;]*)/);
    if (w.parent!=w){f=b;b=c;c=f;};u='//stats.ipinyou.com/cvt?a='+e('Nbs.R7s.vgO7KQFiezmPWJF2VlBeGX')+'&c='+e(h?h[2]:'')+'&s='+e(i?i[2].match(/jump\%3D(\d+)/)[1]:'')+'&u='+e(b)+'&r='+e(c)+'&rd='+(new Date()).getTime()+'&e=';
    (new Image()).src=u;
}